<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>聊天室-用户注册</title>
</head>
<body>
	<form action="../regist.do" method="post">
		<table align="center" style="border: 1px solid gray">
			<tr align="center">
				<td colspan="2">注册</td>
			</tr>
			<tr>
				<td>用户名:</td>
				<td><input type="text" id="username" name="username"></td>
			</tr>
			<tr>
				<td>密 码:</td>
				<td><input type="password" id="password" name="password"></td>
			</tr>
			<tr>
				<td>确认密 码:</td>
				<td><input type="password" id="password2" name="password2"></td>
			</tr>
			<tr>
				<td>名称:</td>
				<td><input type="text" id="name" name="name"></td>
			</tr>
			<tr>
				<td>性别:</td>
				<td><input type="text" id="sex" name="sex"></td>
			</tr>
			<tr>
				<td>年龄:</td>
				<td><input type="text" id="age" name="age"></td>
			</tr>
			<tr>
				<td>电话号码:</td>
				<td><input type="text" id="tel" name="tel"></td>
			</tr>
			<tr>
				<td>生日:</td>
				<td><input type="text" id="birthday" name="birthday"></td>
			</tr>
			<tr>
				<td>邮箱:</td>
				<td><input type="text" id="mail" name="mail"></td>
			</tr>
			
			<tr align="center">
				<td colspan="2">
					<input type="button" onclick="regist()" value="注册"> 
					<input type="reset" value="重置">
					<input type="button" onclick="toLogin()" value="返回登录">
				</td>
			</tr>
		</table>
	</form>
</body>
<script type="text/javascript">
	function toLogin() {
		window.location.href = "<%=request.getContextPath()%>/index.jsp";
	}
	function regist() {
		var username = document.getElementById("username");
		var psw = document.getElementById("password");
		var psw2 = document.getElementById("password2");
		var name = document.getElementById("name");
		if (username.value.length == 0 || username.value == "") {
			alert("请输入用户名!");
			return false;
		} else if (psw.value.length == 0 || psw.value == "") {
			alert("请输入密码!");
			return false;
		} else if (psw2.value.length == 0 || psw2.value == "") {
			alert("请输入确认密码!");
			return false;
		} else if (psw.value != psw2.value) {
			alert("密码输入不一致！");
			psw.value = "";
			psw2.value = "";
		} else if (name.value.length == 0 || name.value == "") {
			alert("请输入名称!");
			return false;
		} 
		document.forms[0].submit();

	}
</script>
</html>